(function(){
  const storage = {
    get(key) {
      if (!key) return;
      let data = this.data();
      return data[key];
    },
    set(key, value = "") {
      if (!key) return;
      let data = this.data();
      data[key] = value;
      localStorage.setItem("MetalSlug", JSON.stringify(data));
    },
    remove(key) {
      if (!key) return;
      let data = this.data();
      delete data[key];
      localStorage.setItem("MetalSlug", JSON.stringify(data));
    },
    clear() {
      localStorage.removeItem("MetalSlug");
    },
    data() {
      let data = localStorage.getItem("MetalSlug");
      return data ? JSON.parse(data) : {};
    },
    updateMovement(data) {
      this.set("movements", data);
    },
    updateFavorite(data) {
      this.set("favorites", data);
    }
  };
  const uuid = function () {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      var r = (Math.random() * 16) | 0,
        v = c == 'x' ? r : (r & 0x3) | 0x8;
      return v.toString(16);
    });
  }
  window.uuid = uuid;
  window.storage = storage;
}(window));